<?php
class UserFaqController  extends Zone_Action{
	public function indexAction(){			
		$posts = $this
			->Model
			->fetchAll("SELECT * FROM `faqs` WHERE `is_menu`='yes' ORDER BY `ord`");
		
	
		$this->set(array(
			posts	=> $posts
		));	
		$this->removeLayout();
	}
	
	public function viewAction(){
		$post_id = get('ID');
		$posts = $this
			->Model
			->fetchAll("SELECT * FROM `faqs` 
				WHERE `is_menu`='no' 
					AND `parent_id`='$post_id'
				ORDER BY `ord`");
		$this->set(array(
			posts	=> $posts
		));	
		$this->removeLayout();				
	}
	
	public function searchAction(){
		$s = get('faq_s');
		$posts = $this
			->Model
			->fetchAll("SELECT * FROM `faqs` 
				WHERE `is_menu`='no' 
					AND ( `title` LIKE '%$s%' OR `content` LIKE '%$s%' )
				ORDER BY IF(`title` LIKE '%$s%',0,1)");
		$this->set(array(
			posts	=> $posts
		));
	
		$this->removeLayout();	
		$this->setView('FaqView');	
	}	
}
?>